package com.cjl.learn.bean;

import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Value;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

/**
 * Created by Enzo Cotter on 2019-07-21.
 */
public class Bird implements InitializingBean, DisposableBean {

    @Value("lucy")
    private String name;

    public Bird() {
        System.out.println("Bird... constructor, name=" + name);
    }

    public void initMethod() {
        System.out.println("Bird...initMethod");
    }

    public void destroyMethod() {
        System.out.println("Bird...destroyMethod");
    }

    @Override
    public void afterPropertiesSet() {
        System.out.println("Bird....InitializingBean#afterPropertiesSet");
    }

    @Override
    public void destroy() {
        System.out.println("Bird....DisposableBean#destroy");
    }

    @PostConstruct
    public void postConstruct() {
        System.out.println("Bird...postConstruct, name=" + name);
    }

    @PreDestroy
    public void preDestroy() {
        System.out.println("Bird...preDestroy");
    }

    public String getName() {
        return name;
    }
}
